package main

import "fmt"

func main() {

	fibSlice := Fibonacci(10)
	fmt.Printf("fibnacci(%d) is: %v \n", 10, fibSlice)
}
func Fibonacci(n int) []int {
	fibSlice := make([]int, 0, n)
	for i := 0; i < n; i++ {
		if i == 0 || i == 1 {
			fibSlice = append(fibSlice, i)
		} else {
			fibSlice = append(fibSlice, AddLastTwoEle(fibSlice))
		}
	}
	return fibSlice
}

func AddLastTwoEle(fibSlice []int) int {
	last := fibSlice[len(fibSlice)-1]
	lastSecond := fibSlice[len(fibSlice)-2]
	return last + lastSecond
}
